import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

//1.创建路由组件
import Home from '../views/Home'
import User from '../views/User'
import Main from '../views/Main'
import Mall from '../views/Mall'
import PageOne from '../views/PageOne'
import PageTwo from '../views/PageTwo.vue'
import Login from '../views/Login'
// 0. 如果使用模块化机制编程，导入Vue和VueRouter，要调用 Vue.use(VueRouter)


//2、将路由与组件进行映射
const routes = [
    {
        //主路由
        path: '/',
        component: Main,
        name: 'Main',
        redirect: '/home',
        children: [
            // {path: 'home', name: 'home', component: Home},// 主页
            // {path: 'user', name: 'user', component: User},// 用户管理
            // {path: 'mall', name: 'mall', component: Mall},// 商品管理
            // {path: 'page1', name: 'page1', component: PageOne},// 页面1
            // {path: 'page2', name: 'page2', component: PageTwo},// 页面2
        ]
    },
    {
        path : '/login',
        name: 'login',
        component: Login
    }
]


// 3. 创建 router 实例，然后传 `routes` 配置
const router = new VueRouter({
    routes // (缩写) 相当于 routes: routes
  })
  
  //将router实例进行对外暴露
  export default router